package com.liutaw.nanjingair.views.viewcomponent;

/**
 * Created by liutaw on 2015/12/12.
 */
// 验证码倒计时

import android.os.CountDownTimer;

/**
 * 计时器.
 */
public class TimerCount extends CountDownTimer {
    /**
     * button 外部按钮.
     */
    private NumberCallBack callBack;

    /**
     * @param millisInFuture    总共时间多长
     * @param countDownInterval 时间间隔
     * @param button            对应的按钮
     */
    public TimerCount(long millisInFuture, long countDownInterval, NumberCallBack callBack) {
        super(millisInFuture, countDownInterval); // 参数依次为总时长,和计时的时间间隔
        this.callBack = callBack;
    }

    @Override
    public void onFinish() { // 计时完毕时触发
       callBack.onFinished();
    }

    @Override
    public void onTick(long millisUntilFinished) { // 计时过程显示
        callBack.onCount(millisUntilFinished / 1000 + "s");
    }
    public interface NumberCallBack {
        void onCount(String count);
        void onFinished();
    }
}